<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <!-- 引入人家提供的依赖包 -->
    <script src="https://cdn.bootcdn.net/ajax/libs/echarts/5.3.3/echarts.min.js"></script>
    <style>
        * {
            margin: 0;
            padding: 0;
        }

        .box {
            width: 1000px;
            height: 400px;
            border: 1px solid black;
        }
    </style>
</head>

<body>
    <!-- 准备一个具有一定高度的容器 -->
    <div class="box"></div>
</body>

</html>
<script>
    //初始化echarts实例
    let mycharts = echarts.init(document.querySelector('.box'));
    //通过echarts实例方法setOption方法初始化各种图形图标
    //准备配置对象
    let options = {
        title: {
            text: '折线图'
        },
        xAxis: {
            type: 'category',
            //两边不留白
            boundaryGap: false
        },
        yAxis: {
            //y轴的轴线
            axisLine: {
                show: true
            }
        },
        //提示文字
        tooltip: {},
        series: {
            type: 'line',//折线图
            data: [10, 44, 24, 127, 9, 37, 19],
            //是否平滑曲线显示
            smooth: true,

            //拐点形状
            // symbol:'none',
            label: {
                show: true
            },
            //拐点样式
            itemStyle: {
                color: 'white'
            },
            //填充区域
            areaStyle: {
                //填充颜色
                color: {
                    type: 'linear',
                    x: 0,
                    y: 0,
                    x2: 0,
                    y2: 1,
                    colorStops: [{
                        offset: 0, color: 'black' // 0% 处的颜色
                    }, {
                        offset: 1, color: 'white' // 100% 处的颜色
                    }],
                    global: false // 缺省为 false
                }
            },
            //线条的颜色
            lineStyle: {
                color: {
                    type: 'linear',
                    x: 0,
                    y: 0,
                    x2: 0,
                    y2: 1,
                    colorStops: [{
                        offset: 0, color: 'yellow' // 0% 处的颜色
                    }, {
                        offset: 1, color: 'green' // 100% 处的颜色
                    }],
                    global: false // 缺省为 false
                }
            }
        }
    }
    //设置配置项
    mycharts.setOption(options);
</script>